<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
       function getProTest(){
        return new Promise (function(resolve,reject){   
            setTimeout(()=>{
                resolve()
                console.log('你已经成功执行了'+resolve);
            },Math.random()*1000),
            setTimeout(()=>{
                reject()
                console.log('执行失败返回'+reject);
            },Math.random()*1000)
        });
        console.log(p1);
        p1.then(res=>{
            console.log('成功了'+res);
        })
        p1.catch(err=>{
            console.log('失败了'+err);
        })
       }

       console.log(getProTest());




        let p1 = new Promise (function(resolve,reject){   
            setTimeout(()=>{
             
                resolve()
                console.log('你已经成功执行了'+resolve);
            },Math.random()*1000),
            setTimeout(()=>{
                reject()
                console.log('执行失败返回'+reject);
            },Math.random()*1000)
        });
        console.log(p1);
        p1.then(res=>{
            console.log('成功了'+res);
        })
        p1.catch(err=>{
            console.log('失败了'+err);
        })


        let p2 = new Promise (function(resolve,reject){   
            setTimeout(()=>{
             
                resolve()
                console.log('你已经成功执行了'+resolve);
            },Math.random()*1000),
            setTimeout(()=>{
                reject()
                console.log('执行失败返回'+reject);
            },Math.random()*1000)
        });

        let p3 = new Promise (function(resolve,reject){   
            setTimeout(()=>{
             
                resolve()
                console.log('你已经成功执行了'+resolve);
            },Math.random()*1000),
            setTimeout(()=>{
                reject()
                console.log('执行失败返回'+reject);
            },Math.random()*1000)
        });
        // let p = Promise.all({p1,p2,p3}); 
        let proall = Promise.all([p1,p2,p3])

        let proall2 =Promise.race([p1,p2,p3])
        console.log(proall);
        console.log(proall2);
        proall.then(res=>{
            console.log(res);
        })

        // proal2.then(res=>{
        //     console.log(res);
        // })

























    </script>
    
</body>
</html>